<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>url切割</title>
  </head>
  <body></body>
  <script>
    var cs = location.search;
    var arr = [];
    var obj = {};
    if (cs != "") {
      cs = cs.slice(1);
      console.log(cs);
      if (cs.indexOf("&") != -1) {
        arr = cs.split("&");
      } else {
        arr[0] = cs;
      }
      arr.forEach((v, k, a) => {
        var lsArr = v.split("=");
        obj[lsArr[0]] = lsArr[1];
      });
      console.log(obj);
    }
  </script>
</html>
